<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<include file="Public:meta" />
    <style>
    	.InputType1{ color:black;}
		.InputType2{ color:green;}
		.InputType3{ color:blue;}
		
		.ValueType1{ color:black;}
		.ValueType2{ color:green;}
		.ValueType3{ color:blue;}
    </style>
</head>
<body id="main_page">
<include file="Public:position" />
<div class="container">
    <form enctype="multipart/form-data" method="post" id="frm">
        <div class="table">
           <div class="toolbars">
                <li class="toolbar"><a id="btnBack" href="{$Url}index" target="_self" title="返回">返回</a></li>
                <li class="toolbar"><a id="btnSaveAll" href="{$Url}addAttribute/TypeID/{$TypeID}"  title="添加一个分组" target="_self">添加一个属性</a></li>
                <li class="toolbar"><a id="selectall" onclick="CheckAll()"  title="全选">全选</a></li>
                <li class="toolbar"><a id="del" onclick="batchDel()" title="批量删除">删除</a></li>
                <li class="toolbar"><a id="sortall" onclick="sort()" title="批量排序">排序</a></li>
                <li class="toolbar toolbarform">
                    <label>所属类型</label>
                    <select name="TypeID" id="TypeID">
                        <volist name="Type" id="t">
                            <eq name="t.TypeID" value="$TypeID">
                                <option value="{$t.TypeID}" selected="selected">{$t.TypeName}</option>
                            <else/>
                                <option value="{$t.TypeID}">{$t.TypeName}</option>
                            </eq>
                        </volist>
                    </select>
                    <input id="btnSeek" class="btnToolbarForm" type="submit" value="查询" onclick="Search()">
                </li>
            </div>
            <table class="datatable" id="datatable">
                <tr>
                     <th width="45px"  nowrap="nowrap">选中</th>
                     <th width="60px" >属性ID</th>
                     <th>属性名称</th>
                     <th width="70px" >被使用数</th>
                     <th width="120px" >所属分组</th>
                     <th width="60px" >排序</th>
                     
                     
                     <th width="90px" >属性值类型</th>
                     <th width="80px" >录入方式</th>
                     <th width="120px" >是否作为检索条件</th>
                     <th width="75px" >是否启用</th>
                     <th width="150px">操作</th>
                </tr>  
                <notempty name="Data">
                <volist name="Data" id="d">
                    <tr>
                        <td><input class="checkrow" type="checkbox" name="id[]" value="{$d.TypeAttributeID}" /></td>
                        <td>{$d.TypeAttributeID}</td>
                        <td>{$d.TypeAttributeName}</td>
                        <td style="color:red;">{$d.UsedCount}</td>
                        <td style="font-weight:bold;color:blue;">{$d.TypeGroupName}</td>
                        <td><input type="text" class='textinput' onclick="this.select()" style="width:50px" name="OrderNumber[]" value="{$d.TypeAttributeOrder}" />
                            <input type="hidden" class='textinput' name="OrderID[]" value="{$d.TypeAttributeID}" />
                        </td>
                        
                        <td>
                            <span class="ValueType{$d.ValueType}">
                                <switch name="d.ValueType">
                                    <case value="1">唯一属性</case>
                                    <case value="2">单选属性</case>
                                    <case value="3">复选属性</case>
                                </switch>
                            </span>
                        </td>
                        <td>
                            <span class="InputType{$d.InputType}">
                                <switch name="d.InputType">
                                    <case value="1">手工录入</case>
                                    <case value="2">从列表选择</case>
                                    <case value="3">多行文本框</case>
                                </switch>
                            </span>
                        </td>
                        <td>
                             <eq name="d.IsSearch" value="1">
                                <span style="color:#F00;cursor:pointer;"  onclick="toggleStatus(this,{$d.TypeAttributeID},'type_attribute','否',0,'#000','是',1,'#f00','IsSearch')">是</span>
                            <else/>
                                <span style="color:#000;cursor:pointer;"  onclick="toggleStatus(this,{$d.TypeAttributeID},'type_attribute','否',0,'#000','是',1,'#f00','IsSearch')">否</span>
                            </eq>
                        </td>
                        <td>
                            <eq name="d.IsEnable" value="1">
                                <span style="color:#000;cursor:pointer;"  onclick="toggleStatus(this,{$d.TypeAttributeID},'type_attribute')">启用</span>
                            <else/>
                                <span style="color:#F00;cursor:pointer;"  onclick="toggleStatus(this,{$d.TypeAttributeID},'type_attribute')">禁用</span>
                            </eq>
                        </td>
                        <td class="operator">
                            <a style="float:left" href="{$Url}modifyAttribute/id/{$d.TypeAttributeID}/TypeID/{$TypeID}" id="btnEdit">修改</a>
                            <div class="btn-sep"></div>
                            <a style="float:left" onclick="del({$d.TypeAttributeID})" class="btnDel">删除</a>
                        </td>
                    </tr>
                </volist>
                <else/>
                    <tr><td colspan="11" id="NoData">{$Think.lang.NoDataTip}</td></tr>
                </notempty>                                  
            </table>
             <div class="tfoot">
             	<div id="notice">
                	<b>说明：</b><span class="notice-item">删除属性会同时删除信息中使用该属性的属性值，请谨慎操作</span>
            	</div>
             </div>
        </div>
    </form>
</div>
</body>
</html>
<script type="text/javascript">
function del(id){
	$.confirm("{$Think.lang.DeleteTip}", function () {
		url = "{$Url}delAttribute/TypeID/{$TypeID}/id/"+id;
		location.href = url;
	}, function () {
		return true;
	});
}

function batchDel(){
	//var arrChk = $("input[name='InfoID[]'][checked]"); //在高速浏览器长度总是返回0
	var arrChk = $("input[name='id[]']");
	var n = 0;
	for(var i = 0; i < arrChk.length; i++){
		if(arrChk[i].checked) n++;
	}
	
	if( n == 0 ) {
		WarnBox("{$Think.lang.CheckDeleteTip}");
		return;
	}
	
	$.confirm("{$Think.lang.DeleteTip}", function () {
		$('#frm').attr("action", "__URL__/delAttribute/TypeID/{$TypeID}");
		$('#frm').submit();
	}, function () {
		return true;
	});
}

function sort(){
	$.confirm("{$Think.lang.SortTip}", function () {
		$('#frm').attr("action", "__URL__/sortAttribute/TypeID/{$TypeID}");
		$('#frm').submit();
	}, function () {
		return true;
	});
}

function Search(){
	$('#frm').attr("action", "{$Url}attribute");
	$('#frm').submit();
	return true;
}
</script>